package com.gnerv.battle.boot.framework.repository;

import com.gnerv.battle.boot.framework.model.bo.LoginAccountDetailsBO;
import com.gnerv.battle.boot.framework.model.dto.ManageAccountDTO;
import com.gnerv.battle.boot.framework.model.entity.ManageAccount;
import com.gnerv.battle.boot.framework.repository.mapper.ManageAccountMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Gnerv LiGen
 */
@Component
@AllArgsConstructor
public class ManageAccountRepository {

    private ManageAccountMapper manageAccountMapper;

    public long insert(ManageAccount manageAccount) {
        return manageAccountMapper.insert(manageAccount);
    }

    public long deleteByUkId(String ukId) {
        return manageAccountMapper.deleteByUkId(ukId);
    }

    public long updateDeletedByUkId(String ukId) {
        return manageAccountMapper.updateDeletedByUkId(ukId);
    }

    public long updateByUkId(ManageAccount manageAccount) {
        return manageAccountMapper.updateByUkId(manageAccount);
    }

    public ManageAccountDTO selectByUkId(String ukId) {
        return manageAccountMapper.selectByUkId(ukId);
    }

    public List<ManageAccountDTO> listByUsername(String username, Integer page, Integer size) {
        return manageAccountMapper.listByUsername(username, page, size);
    }

    public long countByUsername(String username) {
        return manageAccountMapper.countByUsername(username);
    }

    public boolean isExist(String username) {
        return manageAccountMapper.isExist(username) != 0;
    }

    public LoginAccountDetailsBO selectAccountDetailsByUsername(String username) {
        return manageAccountMapper.selectAccountDetailsByUsername(username);
    }
}
